<?php
function outFormat(int $width, ?array $a): void
{
    if (empty($a)) {
        return;
    }

    foreach ($a as $item) {
        $text = str_replace(' ', '', $item);

        if ($text === '') {
            continue;
        }

        $hex = bin2hex($text);
        $hex = strtoupper($hex);
        $hex = implode('_', str_split($hex, 2));
        $textWidth = mb_strwidth($text);
        $hexLength = strlen($hex);

        $padLength = $width - $textWidth - $hexLength;
        if ($padLength < 1) {
            $output = $text . ' ' . $hex;
        } else {
            $output = $text . str_repeat(' ', $padLength) . $hex;
        }

        echo $output . PHP_EOL;
    }
}
$a = ['张三丰', '里  斯', '阿 kit', 'papi 酱', 'Jackson'];
outFormat(35, $a);